/**
 * Created with Intellij IDEA
 * Description
 * User:ASUS
 * Date:2024-05-15
 * Time:20:53
 */
// Animal类
class Animal {
    public void eat() {
        System.out.println("动物正在吃东西...");
    }
    public void walk() {
        System.out.println("动物正在行走...");
    }
}
// Pet接口
interface Pet {
    void setName(String name);
    String getName();
    void eat(); // 声明eat方法
}
// Dog类
class Dog extends Animal implements Pet {
    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    // Dog特有的方法，比如巡山
    public void walkDog() {
        System.out.println(getName() + "出门巡山");
    }
    public void eat() {
        System.out.println("狗狗正在吃东西...");
    }
}

// Cat类
class Cat extends Animal implements Pet {
    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
    public void eat() {
        System.out.println("猫咪正在吃东西...");
    }

    // Cat特有的方法，比如打猎
    public void walkCat() {
        System.out.println(getName() + "出门打猎");
    }
}
class PetShop {

    public void raise(Pet pet) {
        pet.eat();
    }

    public void setName(Pet pet, String name) {
        pet.setName(name);
    }
}
class Test {
    public static void main(String[] args) {
        PetShop ps = new PetShop();
        Dog d1 = new Dog();
        Cat c1 = new Cat();

        ps.raise(d1);
        ps.raise(c1);

        ps.setName(d1, "旺财");
        ps.setName(c1, "小咪");

        d1.walkDog();
        c1.walkCat();
    }
}